<template>
  <div class="travelOrderRefund">
    <el-form :model="results" :inline="true" size="mini" ref="ruleForm" label-width="100px">
      <div style="margin: 20px">
        <!-- <el-form-item label="团类型">
          <el-select v-model="results.a" placeholder="请选择">
            <el-option
              v-for="item in groupType"
              :key="item.label"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="团状态">
          <el-select v-model="results.a" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.label"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="团名称">
          <el-input v-model="results.groupName"></el-input>
        </el-form-item>

        <!-- <el-form-item label="订单号">
          <el-input v-model="results.a"></el-input>
        </el-form-item> -->
        <el-form-item label="会员姓名">
          <el-input v-model="results.customerName"></el-input>
        </el-form-item>
        <el-form-item label="会员手机号">
          <el-input v-model="results.customerPhone"></el-input>
        </el-form-item>
        <el-form-item label="会员id">
          <el-input v-model="results.customerId"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="viewproduct">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <!-- 表格数据 -->
    <el-table :data="tableData" :header-cell-style="{
        color: '#fff',
        background: '#6090EC',
        fontSize: '11px',
        fontWeight: 'normal',
      }" size="mini" border>
      <el-table-column prop="orderId" label="订单号" width="100">
      </el-table-column>
      <!-- <el-table-column prop="countryType" label="团类型" width="150">
        <template slot-scope="scope">
          <template v-if="scope.row.countryType == 'domesticGroup'"
            >国内团</template
          >
          <template v-if="scope.row.countryType == 'foreignMissions'"
            >国外团</template
          >
        </template>
      </el-table-column> -->
      <el-table-column prop="groupName" label="团名称" width="100">
      </el-table-column>
      <el-table-column prop="groupName" label="团号" width="100">
      </el-table-column>
      <el-table-column prop="customerName" label="会员姓名"></el-table-column>
      <el-table-column prop="customerPhone" label="会员卡号"></el-table-column>
      <el-table-column prop="customerId" label="会员手机"></el-table-column>
      <el-table-column prop="refundamount" label="退款金额"></el-table-column>
      <el-table-column prop="refundstatus" label="状态">
        <template slot-scope="scope">
          <template v-if="scope.row.refundstatus == 0">未审核</template>
          <template v-if="scope.row.refundstatus == 1">已审核</template>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="statusId" label="订单状态">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId == 0">未上架</template>
          <template v-if="scope.row.statusId == 1">已上架</template>
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="审核状态">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId == 0">未上架</template>
          <template v-if="scope.row.statusId == 1">已上架</template>
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="是否退款">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId == 0">未上架</template>
          <template v-if="scope.row.statusId == 1">已上架</template>
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="退款类型">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId == 0">未上架</template>
          <template v-if="scope.row.statusId == 1">已上架</template>
        </template>
      </el-table-column> -->
      <el-table-column prop="failedreason" label="退单原因"></el-table-column>

      <el-table-column label="操作" width="520">
        <template slot-scope="scope">
          <!-- <el-button slot="reference" type="primary" size="mini" @click="Mgroupodify(scope.row)">修改支付方式</el-button> -->
          <!-- <el-button slot="reference" type="primary" size="mini" @click="viewgroup(scope.row)">退款</el-button> -->
          <!-- <el-button slot="reference" type="primary" size="mini" @click="twocollection(scope.row)">二次收款</el-button> -->
          <!-- <el-button slot="reference" type="primary" size="mini" @click="confirmation(scope.row)">生成确认函</el-button> -->
          <el-button slot="reference" type="primary" size="mini" @click="shelves(scope.row)">详情</el-button>
          <el-button slot="reference" v-if="scope.row.refundstatus == 0" type="primary" size="mini"
            @click="raincheck(scope.row)">审核</el-button>

        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      :page-sizes="[10, 15, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
      :total="pageTotal">
    </el-pagination>
    <el-dialog title="退单详情" :visible.sync="refundDialogVisible" width="30%" :before-close="handleClose">
      <div>
        <div style="display:flex">
          <span>订单号：</span>
          <span>{{infofrom.orderId}}</span>
        </div>
        <div style="display:flex">
          <span>团名称：</span>
          <span>{{infofrom.groupName}}</span>
        </div>
        <div style="display:flex">
          <span>退订日期：</span>
          <span>{{infofrom.applytime}}</span>
        </div>
        <div style="display:flex">
          <span>退订金额：</span>
          <span>{{infofrom.refundamount}}</span>
        </div>
        <div style="display:flex">
          <span>会员名称：</span>
          <span>{{infofrom.customerName}}</span>
        </div>
        <div style="display:flex">
          <span>会员手机：</span>
          <span>{{infofrom.customerPhone}}</span>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="refundDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="refundDialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="审核" :visible.sync="AudiodialogVisible" width="30%" :before-close="handleClose">
      <el-form ref="form" :model="failedreasonfrom" label-width="80px">
        <el-form-item label="退单原因">
          <el-input v-model="failedreasonfrom.failedreason"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="AudiodialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="geteditOrderRefund">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "travelOrderRefund",
    data() {
      return {
        failedreasonfrom: {
          failedreason: ""
        },
        AudiodialogVisible: false,
        refundDialogVisible: false,
        // 团类型
        groupType: [{
            value: "",
            label: "全部",
          },
          {
            value: "domesticGroup",
            label: "国内团",
          },
          {
            value: "foreignMissions",
            label: "国外团",
          },
        ],
        // 查询数据
        results: {
          customerId: "",
          customerName: "",
          groupName: "",
          customerPhone: "",
        },
        // 列表数据
        tableData: [

        ],
        // 详情数据
        infofrom: {},
        // 分页
        pageTotal: 0,
        pageSize: 1,
        currentPage: 10,
      };
    },
    methods: {
      // 审核按钮
      raincheck(row) {
        console.log(row)
        this.auditid = row.orderrefundid
        this.AudiodialogVisible = true
      },
      // 查询按钮
      viewproduct() {
        localStorage.setItem("pageSize", 10);
        localStorage.setItem("pageNum", 1);
        this.getorderRefundlist()
      },
      //分页
      handleSizeChange(value) {
        console.log("1", value);
        localStorage.setItem("pageSize", value);
        localStorage.setItem("pageNum", 1);
        this.getorderRefundlist();
        this.pageSize = value;
      },
      handleCurrentChange(value) {
        console.log("2", value);
        localStorage.setItem("pageNum", value);
        localStorage.setItem("pageSize", this.pageSize);
        this.getorderRefundlist();
        // orders = res.data;
      },
      shelves(row) {
        console.log(row)
        this.$axios.getOrderRefund({
          orderRefundId: row.orderrefundid
        }).then((res) => {
          if (res.code == "200") {
            this.infofrom = res.data
          }
        });
        this.refundDialogVisible = true
      },
      // 列表接口
      getorderRefundlist() {
        this.$axios.getorderRefundlist({
          customerId: this.results.customerId,
          customerName: this.results.customerName,
          groupName: this.results.groupName,
          customerPhone: this.results.customerPhone,

        }).then((res) => {
          if (res.code == "200") {
            this.tableData = res.data
            this.pageTotal = res.data.length
          }
        });
      },
      // 审核接口
      geteditOrderRefund() {
        this.$axios.geteditOrderRefund({
          refundstatus: 1,
          orderrefundid: this.auditid,
          failedreason: this.failedreasonfrom.failedreason
        }).then((res) => {
          if (res.code == "200") {
            this.$message({
              message: '审核成功',
              type: 'success'
            });
            this.AudiodialogVisible = false
            this.getorderRefundlist()
          }
        });
      },
    },
    mounted() {
      this.getorderRefundlist()
    },
  };
</script>

<style scoped>
</style>